import {getUserInfo} from "@/request/Api";
import {params} from "@/enums/PublicEnums";
export default {
    namespaced:true,
    mutations:{
        // 设置用户信息
        setUserInfoData(state,data){
            state.userInfoData=data
            localStorage.setItem(params.userinfo,JSON.stringify(data));
        }
    },
    actions:{
        //发送请求 获取用户信息
        async userInfoDataRequest({commit}){
            let result =await getUserInfo()
            commit(params.setUserInfoData,{
                permissions: result.permissions,
                user: result.user,
                roles: result.roles
            })
        }
    },
    state:{
        userInfoData: {
            user: {},
            roles: [],
            permissions: []
        }
    },
    getters:{
        getUserInfoData(state){
            return state.userInfoData
        }
    }
}
